﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using qna.Services;
using qna.Business;

namespace qna.pages {
	public partial class EditQuestion : System.Web.UI.Page {
		protected void Page_Load(object sender, EventArgs e) {
			if (Request.QueryString["id"] == null) {
				Response.Redirect("~/pages/Questions.aspx");
			} else {
				var s = new QuestionService();
				if (IsPostBack) {
					s.Update(Convert.ToInt32(Request.QueryString["id"]), questionForm.GetTitle(), questionForm.GetContent(), questionForm.GetSubject());
					Response.Redirect("~/pages/AnswerQnA.aspx?view=" + Request.QueryString["id"]);
				} else {
					questionForm.Question = s.Get(Convert.ToInt32(Request.QueryString["id"]));
				}
			}
		}
	}
}